<template>
	<view class="content"
		:style="'background: url('+ c_imgPath + 'indexBg.png'+ ') repeat-y 0 0 / 100% auto;'">
		<view class="header">
			<view class="qiehuan_box">
				<view class="qiehuan">
					<view @click="getlist(v.id)" v-for="(v,i) in arr" :key="i">
						<view :class="show==v.id?'xzs':'wzs'">{{v.name}}</view>
						<view class="qiehuan_line" v-if="show==v.id">
							<image :src="c_imgPath+'xzs_sel.png'"></image>
						</view>
					</view>
				</view>
				<!-- <image :src="z_imgPath + 'bangdan/guize.png'" @click="$refs.shuoming.open()"></image> -->
			</view>
			<view class="header_title">
				<!-- <view> <text>{{date}}</text> </view> -->
				<view class="flex_center">
					<xwCountDown :is-day="true" :tip-text="'结算倒计时：'" :datatime="end_date">
					</xwCountDown>
				</view>
				<view class="header_title_gz" @click="$refs.shuoming.open()">
					<image :src="c_imgPath+'bdgz.png'"></image>
					<text>榜单规则</text>
				</view>
			</view>
		</view>

		<mescroll-body ref="mescrollRef" @init="mescrollInit" :down="downOption" @down="downCallback" @up="upCallback">
			<view class="list">
				<view class="list_box">
					<view class="list_box_item left">
						<view class="list_box_item_img" v-if="listdata[1].headimg">
							<image :src="listdata[1].headimg"></image>
						</view>
						<view class="list_box_item_zanwu" v-else>
							暂无
						</view>
						<view class="list_box_item_name hang1">{{listdata[1].nickname || '暂无'}}</view>
					</view>
					<view class="list_box_item center">
						<view class="list_box_item_img" v-if="listdata[0].headimg">
							<image :src="listdata[0].headimg"></image>
						</view>
						<view class="list_box_item_zanwu" v-else>
							暂无
						</view>
						<view class="list_box_item_name hang1">{{listdata[0].nickname || '暂无'}}</view>
					</view>
					<view class="list_box_item right">
						<view class="list_box_item_img" v-if="listdata[2].headimg">
							<image :src="listdata[2].headimg"></image>
						</view>
						<view class="list_box_item_zanwu" v-else>
							暂无
						</view>
						<view class="list_box_item_name hang1">{{listdata[2].nickname || '暂无'}}</view>
					</view>
				</view>
				<view class="list_box_bg"
					:style="'background: url('+ c_imgPath + 'jiangtai.png'+ ') repeat-y 0 0 / 100% 100%;'">
					<view class="jp_box">
						<view class="jp_box_img">
							<image :src="listdata[1].prize_imgurl"></image>
						</view>
						<view class="jp_box_text hang2">{{listdata[1].prize_title}}</view>
					</view>
					<view class="jp_box1">
						<view class="jp_box_img">
							<image :src="listdata[0].prize_imgurl"></image>
						</view>
						<view class="jp_box_text hang2">{{listdata[0].prize_title}}</view>
					</view>
					<view class="jp_box3">
						<view class="jp_box_img">
							<image :src="listdata[2].prize_imgurl"></image>
						</view>
						<view class="jp_box_text hang2">{{listdata[2].prize_title || ''}}</view>
					</view>
				</view>
			</view>
			<view class="phb_item">
				<view v-for="(item,index) in listdata" :key="index" class="qbt_con_item" v-if="index > 2"
					:style="'background: url('+ c_imgPath + 'paihangbangBg.png'+ ') repeat-y 0 0 / 100% 100%;'">
					<view class="item_num">{{index + 1}}</view>
					<image :src="item.headimg" class="headimg"></image>
					<view class="hang2" style="flex: 1;">{{item.nickname}}</view>
					<image :src="item.prize_imgurl" class="jiangpin"></image>
					<view class="hang2" style="font-size: 20rpx;font-weight: bold;">{{item.prize_title}}
					</view>
				</view>
			</view>
		</mescroll-body>
		<!-- 我的排名 -->
		<view class="my_paiming"
			:style="'background: url('+ c_imgPath + 'paiming.png'+ ') repeat-y 0 0 / 100% auto;'">
			<view>当前我的排名 {{my_rank.my_rank}}</view>
			<view>
				<image :src="my_rank.my_prize_imgurl" class="jiangpin"></image>
				<text class="hang1"
					style="max-width: 200rpx;">
					{{my_rank.my_prize_title}}
				</text>
			</view>
		</view>

		<uni-popup ref="shuoming" type="center">
			<view class="pop"
				:style="'background: url('+ c_imgPath + 'gz_bg.png'+ ') no-repeat 0 0 / 100% 100%;'">
				<view class="pop_con_title">榜单规则</view>
				<view class="pop_con">
					<scroll-view scroll-y="true" style="height: 440rpx;">
						<view v-html="news"></view>
					</scroll-view>
				</view>
			</view>
			<view class="shuoming_close" @click="$refs.shuoming.close()">
				<image :src="cc_imgPath + 'detail/close.png'"></image>
			</view>
		</uni-popup>

	</view>
</template>

<script>
	import xwCountDown from '@/components/xw-CountDown'
	export default {
		components: {
			xwCountDown
		},
		data() {
			return {
				z_imgPath: this.$z_img + 'shouye/',
				c_imgPath: 'https://qt.yhemall.com/shouye/',
				cc_imgPath: 'https://qt.yhemall.com/',
				arr: [{
					name: '周榜单',
					id: 1
				}, {
					name: '月榜单',
					id: 2
				}],
				show: 1,

				listdata: [],
				downOption: {
					auto: false
				},
				date: '',
				end_date: 0,
				my_rank: {},

				news: '',
				border_arr: ['border: 3rpx solid #FF2626;', 'border: 3rpx solid #FFF226;',
					'border: 3rpx solid #0F39EA;'
				]

			}
		},
		onLoad() {
			this.getDanye(7)
		},

		methods: {
			getDanye(e) {
				let that = this;
				that.req({
					url: 'danye',
					data: {
						type: e
					},
					success(res) {
						if (res.status == 1) {
							that.news = res.data
						}
					}
				})
			},
			getlist(v) {
				this.show = v;
				this.listdata = []
				this.mescroll.resetUpScroll()
			},
			/*下拉刷新的回调 */
			downCallback() {
				this.mescroll.resetUpScroll()
			},
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			upCallback(page) {
				//联网加载数据
				this.loadData(page.num);
			},
			loadData(pageNo) {
				// 模拟接口
				let that = this;
				that.req({
					url: that.show == 1 ? 'rank_week' : 'rank_month',
					Loading: true,
					data: {
						page: pageNo,
					},
					success(res) {
						that.mescroll.endByPage(res.data.data.length, 1);
						that.date = res.data.date
						that.end_date = res.data.end_date
						that.my_rank = res.data.my_rank
						if (pageNo == 1) {
							that.listdata = res.data.data;
						} else {
							that.listdata = that.listdata.concat(res.data.data);
						}
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.list{
		width: 690rpx;
		margin: auto;
	}
	.list_box{
		width: 100%;
		color: #FFFFFF;
		position: absolute;
		top: 42rpx;
		z-index: 99;
		.list_box_item{
			position: absolute;
			width: 150rpx;
			text-align: center;
			.list_box_item_img{
				image{
					width: 88rpx;
					height: 88rpx;
					border-radius: 50%;
					background-color: #FFFFFF;
				}
			}
			.list_box_item_zanwu{
				width: 88rpx;
				height: 88rpx;
				margin: auto;
				border-radius: 50%;
				background-color: #FFFFFF;
				text-align: center;
				line-height: 88rpx;
				color: #B75AFF;
				font-size: 24rpx;
				font-weight: bold;
			}
			.list_box_item_name{
				font-size: 28rpx;
			}
		}
		.left{
			left: 50rpx;
			top: 60rpx;
		}
		.center{
			left: 280rpx;
		}
		.right{
			top: 60rpx;
			right: 80rpx;
		}
	}
	.list_box_bg{
		width: 690rpx;
		height: 355rpx;
		top: 173rpx;
		display: flex;
		align-items: center;
		margin: auto;
		position: relative;
		.jp_box,.jp_box1,.jp_box3{
			flex: 1;
			text-align: center;
			.jp_box_img{
				image{
					width: 110rpx;
					height: 110rpx;
					border-radius: 10rpx;
				}
			}
			.jp_box_text{
				font-size: 24rpx;
				color: #FFFFFF;
			}
		}
		.jp_box{
			margin-top: 60rpx;
			.jp_box_text{
				margin: 0 30rpx;
			}
		}
		.jp_box1{
			flex: 1;
			text-align: center;
			.jp_box_img{
				image{
					width: 160rpx;
					height: 160rpx;
				}
			}
		}
		.jp_box3{
			margin-top: 60rpx;
		}
	}
	.phb_item{
		margin-top: 160rpx;
	}
	
	
	
	
	
	
	.my_paiming>view:nth-of-type(2) {
		display: flex;
		align-items: center;
		font-size: 24rpx;
		font-family: Source Han Sans CN;
		font-weight: bold;
		color: #FFFFFF;
		margin-right: 20rpx;
	}

	.my_paiming>view:nth-of-type(1) {
		flex: 1;
		font-size: 32rpx;
		font-family: Source Han Sans CN;
		color: #FFFFFF;
		line-height: 118rpx;
		margin-left: 30rpx;
		// -webkit-text-stroke: 3rpx #FFFFFF;
		// text-stroke: 3rpx #FFFFFF;
	}

	.my_paiming {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		margin: auto;
		width: 100%;
		height: 118rpx;
		display: flex;
		align-items: center;
		// box-sizing: border-box;
	}

	.pop_con {
		height: 440rpx;
		margin: auto;
		padding: 0rpx 36rpx;
		font-size: 24rpx;
		line-height: 36rpx;
		color: #FFFFFF;
		box-sizing: border-box;
		overflow-y: scroll;
	}
	.pop_con_title{
		padding-top: 90rpx;
		padding-bottom: 20rpx;
		text-align: center;
		font-size: 32rpx;
		font-weight: 500;
		background: linear-gradient(0deg, #A98FD3 0%, #FFFFFF 50%);
		-webkit-background-clip: text;
		-webkit-text-fill-color: transparent;
	}


	.pop {
		width: 543rpx;
		height: 801rpx;
		// padding-top: 192rpx;
		box-sizing: border-box;
		/* background: #FFFFFF; */
		/* border-radius: 20rpx; */
	}

	.jiangpin {
		width: 84rpx;
		height: 84rpx;
		border-radius: 7rpx;
		margin-right: 20rpx;
	}

	.headimg {
		width: 76rpx;
		height: 76rpx;
		border-radius: 50%;
		margin: 0 20rpx;
	}

	.paiming {
		width: 80rpx;
		height: 80rpx;
		margin-right: 30rpx;
		font-size: 39rpx;
		font-family: Source Han Sans CN;
		font-weight: bold;
		color: #000000;
		-webkit-text-stroke: 3rpx #FFFFFF;
		text-stroke: 3rpx #FFFFFF;
		text-align: center;
		line-height: 80rpx;
	}

	.qbt_con_item {
		margin: 30rpx auto;
		padding: 0rpx 20rpx 0;
		box-sizing: border-box;
		width: 690rpx;
		height: 98rpx;
		border-radius: 7rpx;
		display: flex;
		align-items: center;
		font-size: 26rpx;
		color: #FFFFFF;
	}



	.qbt_con {
		margin: 0rpx auto;
		width: 710rpx;
		display: flex;
		justify-content: space-between;
		font-size: 24rpx;
		color: #FFFFFF;
		text-align: center;
	}


	.wzs {
		font-size: 28rpx;
		color: #9E99E3;
	}

	.xzs {
		font-size: 32rpx;
		background: linear-gradient(0deg, #B75AFF 0%, #E7CBFF 100%);
		-webkit-background-clip: text;
		-webkit-text-fill-color: transparent;
	}

	.qiehuan_line {
		height: 24rpx;
		image{
			width: 94rpx;
			height: 24rpx;
		}
	}


	.qiehuan>view {
		flex: 1;
		text-align: center;
	}

	.qiehuan {
		width: 100%;
		display: flex;
		justify-content: space-between;
		box-sizing: border-box;
		/* font-family: 'zcq'; */
		font-weight: bold;
	}

	.qiehuan_box>image {
		width: 155rpx;
		height: 57rpx;
	}

	.qiehuan_box {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.header_title {
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 22rpx;
		color: #FFFFFF;
		margin-top: 16rpx;
		.header_title_gz{
			display: flex;
			align-items: center;
			image{
				width: 30rpx;
				height: 30rpx;
				margin-right: 10rpx;
			}
			text{
				font-size: 28rpx;
			}
		}
	}

	.header {
		width: 750rpx;
		/* #ifdef MP */
		top: 0;
		/* #endif */
		/* #ifndef MP */
		top: 88rpx;
		/* #endif */
		left: 0;

		height: 120rpx;
		padding: 0 30rpx;
		box-sizing: border-box;
		position: fixed;
		z-index: 15;
	}

	.content {
		background: #161616;
		width: 100vw;
		min-height: 100vh;
		padding-top: 120rpx;
		box-sizing: border-box;
		box-sizing: border-box;
		position: relative;
		background-attachment: fixed;
	}
</style>
